package net.hiapoe.gsnake4j.window;

import javax.swing.*;

import net.hiapoe.gsnake4j.bean.Drawer;
import net.hiapoe.gsnake4j.bean.Snake;
import net.hiapoe.gsnake4j.listener.MainWinListener;

import java.awt.*;
/**
 * 
 * @Author Administrator
 * @Description 主方法
 * @Version 1.0.3
 * @Date 2013年10月1日
 */
public class RunMe {
	public final static String AUTHOR="Undefined";
	public final static String EMAIL="Undefined";
	public final static String VERSION = "贪食蛇 - v1.0.3";
	public static RunMe window;
	public Canvas canvas;
	public JLabel jlabel;
	public JPanel jpanel;
	public JFrame jframe;

	private RunMe() {
		window = this;
		jframe = new MainWin();
		jframe.setLayout(new BorderLayout());
		Container cp = jframe.getContentPane();
		jlabel = new JLabel("loading...", JLabel.LEFT);
		cp.add(jlabel, BorderLayout.NORTH);

		canvas = new Canvas();
		canvas.setSize(Drawer.CANVAS_WIDTH, Drawer.CANVAS_HEIGHT);
		cp.add(canvas, BorderLayout.CENTER);

		jframe.pack();
		canvas.addKeyListener(MainWinListener.getInstance(jframe));
		// canvas.addKeyListener(new MainWinListener(jframe));
		new Thread(Snake.getInstance()).start();
		new Thread(new Drawer()).start();

	}

	public static void main(String[] args) {
		new RunMe();
	}

}
